package com.bicon.botu.mall.order.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.bicon.botu.mall.order.dto.OrderReceiptDTO;
import com.bicon.botu.mall.order.entity.OrderReceipt;
import com.bicon.botu.mall.order.mapper.OrderReceiptMapper;
import com.bicon.botu.mall.order.service.IOrderChildService;
import com.bicon.botu.mall.order.service.IOrderReceiptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李双喜
 * @date 2018/5/14 12:59
 */
@Service
@Slf4j
public class OrderReceiptServiceImpl extends ServiceImpl<OrderReceiptMapper,OrderReceipt> implements IOrderReceiptService {

    @Autowired
    private OrderReceiptMapper orderReceiptMapper;

    @Autowired
    private IOrderChildService iOrderChildService;

    /**
     * 获得收款信息
     * @param orderGoodsId
     * @return
     */
    @Override
    public List<OrderReceiptDTO> getOrderReceiptInfoList(String orderGoodsId) {
        List<OrderReceiptDTO> receiptDTOList=orderReceiptMapper.getOrderReceiptInfoList(orderGoodsId);
        if(receiptDTOList!=null && receiptDTOList.size()>0){
            //根据用户ID 查询账户
            for (OrderReceiptDTO receiptDTO :receiptDTOList){
                receiptDTO.setUserName(iOrderChildService.checkName(receiptDTO.getUserId()));
            }
        }
        return receiptDTOList;
    }
}
